package com.flower.common.model;

/**
 * 系统返回消息码
 * @author shanks
 * @since 2019 -09-20  17:51
 */
public enum ResultEnum {

    //全局参数开始
    TRANS_SUCCESS("0", "交易成功"),
    INNER_EXCEPTION("-1", "内部错误");
    //退货接口:1101 结束

    private String code;
    private String message;

    ResultEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * Gets code.
     *
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * Gets message.
     *
     * @return the message
     */
    public String getMessage() {
        return message;
    }

    /**
     * Get message string.
     *
     * @param code the code
     * @return the string
     */
    public static String getMessage(String code) {
        for (ResultEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value.getMessage();
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return super.toString();
    }
}
